﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TravelexForwardContracts
{
    public partial class MainForm : Form
    {
        /* *****************************************************
         *  Data Member
         * ****************************************************/
        private XDBOp m_xDb;
        private DataSetCompanyRecords m_dsCompanyRecords;

        /* ******************************************************
         * Public Functions
         * ******************************************************/
        public MainForm()
        {
            InitializeComponent();
            m_xDb = new XDBOp();
            m_dsCompanyRecords = new DataSetCompanyRecords();
        }

        /* ******************************************************
         * Private Functions
         * ******************************************************/
        private void MainForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'travelexForwardContractDataSet1.TCompanyRecords' table. You can move, or remove it, as needed.
            this.tCompanyRecordsTableAdapter1.Fill(this.travelexForwardContractDataSet1.TCompanyRecords);
            // TODO: This line of code loads data into the 'travelexForwardContractDataSet.TCompanyRecords' table. You can move, or remove it, as needed.
            this.tCompanyRecordsTableAdapter.Fill(this.travelexForwardContractDataSet.TCompanyRecords);


        }

        private void CloseButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void SearchButton_Click(object sender, EventArgs e)
        {
            SearchButton.Enabled = false;
            m_dsCompanyRecords = m_xDb.findCompanyRecords(ClientIdComboBox.Text);

            SummaryDataGridView.DataSource = m_dsCompanyRecords;
            SummaryDataGridView.DataMember = "TCompanyRecords";
            SummaryDataGridView.Columns[0].Visible = false;  //client ID
            SummaryDataGridView.Columns[1].Visible = false;  //Client Name
   
        }

        private void newContractsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewContractsForm newContractForm = new NewContractsForm();
            newContractForm.ShowDialog();
        }

        private void ClearButton_Click(object sender, EventArgs e)
        {
            ClinetNameComboBox.Text = "";
            ClientIdComboBox.Text = "";
            SearchButton.Enabled = true;
            SummaryDataGridView.DataSource = null;
        }

        private void ReportLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ReportForm reportForm = new ReportForm();
            reportForm.setDataSet(m_dsCompanyRecords);
            reportForm.ShowDialog();
        }
    }
}